home *** CD-ROM | disk | FTP | other *** search
- /*
- * Main include file for TeX in C.
- * You shouldn't have to change anything in this file except the initial
- * #define's/#undef's, and the default search paths.
- *
- * Tim Morgan December 23, 1987
- * hacked up by David Dermott for MEGAMAX-c
- */
-
- #include <stdio.h>
- #define void int
- /*#undef TRIP*/ /* Create an initex which can run the trip test */
- /*#if defined(INITEX) || defined(TRIP)*/
- #ifdef TRIP
- #define INITEX
- #endif
- #ifdef INITEX
- #define STAT /* Want stats-gathering code */
- #endif
- /*#undef DEBUG */ /* Want debugging code */
-
- /*
- * Search paths for TeX
- */
-
- /*
- * These are the default paths to use, if the user doesn't
- * override with an environment variable or a rooted path
- */
- /*#define TEXFORMATS ".:/usr/uci/lib/tex82"
- #define TEXINPUTS ".:/usr/uci/lib/tex82"
- #define TEXFONTS ".:/usr/uci/lib/fonts/tfm"
- #define TEXPOOL ".:/usr/uci/lib/tex82"
- */
- #define TEXFORMATS ".;\\tex"
- #define TEXINPUTS ".;\\tex\\inputs"
- #define TEXFONTS ".;\\tex\\tfm"
- #define TEXPOOL ".;\\tex"
-
- /* These are used in TeX.web, the change files, and tex.h-defined macros */
- #define inputpathspec 1
- #define readpathspec 2
- #define fontpathspec 3
- #define fmtpathspec 4
- #define poolpathspec 5
-
- extern char *strcpy(), *strcat(); /* From the C library */
-
- /*
- * Global routines implemented as macros, plus some type coercion stuff.
- */
-
- /* This is a workaround to a casting bug in the Sequent Dynix 2.1 C compiler */
- #ifndef sequent
- #define toint(x) ((integer) (x))
- #else
- #define toint(x) ztoint((integer)(x))
- #endif
-
- /*
- * Next, efficiency for Unix systems: use write() instead of stdio
- * to write to the dvi file.
- */
- /* #ifndef UNIX */
- #ifndef VMS
- #define writedvi(a,b) dwrite((char *) &dvibuf[a], (int)sizeof(dvibuf[a]), (int)(b-a+1), dvifile)
- /*#define writedvi(a,b) (void) fwrite((char *) &dvibuf[a], sizeof(dvibuf[a]), (int)(b-a+1), dvifile)
- */
- #else /* unix */
- #define writedvi(a,b) (void) write(fileno(dvifile), (char *) &dvibuf[a],(int)(b-a+1))
- /* #define dumpcore abort */
- #endif /* unix */
-
- #define abs(x) ((x>=0)?(x):(-(x)))
- #define fabs(x) ((x>=0.0)?(x):(-(x)))
- #define Fputs(stream, s) (void) fputs(s, stream)
- #define vstrcpy(a,b) (void) strcpy((a), (b))
- #define inputln(stream, flag) zinputln(stream)
- char zinputln(); /* Get function return type correct=>boolean */
- /*#define dumpthings(base,len) (void) fwrite((char *) &(base), sizeof(base), (int)(len), fmtfile)
- #define undumpthings(base,len) (void) fread((char *) &(base), sizeof(base), (int)(len), fmtfile)
- */
- /* MEGAMAX fwrite fread only allow len<32767 */
- #define dumpthings(base,len) fmtwrite((char *) &(base), sizeof(base), (long)(len), fmtfile)
- #define undumpthings(base,len) fmtread((char *) &(base), sizeof(base), (long)(len), fmtfile)
-
- #define termflush(t) (void) fflush(t)
- #define eof(x) feof(x)
- #define incr(x) ++x
- #define decr(x) --x
- #define uexit(x) exit(x)
- #define odd(x) ((x) & 1)
- #define aopenin(f, p) Openin(&(f), p,"r")
- #define bopenin(f) Openin(&(f), fontpathspec,"br") /* Only used for TFMs */
- #define wopenin(f) Openin(&(f), fmtpathspec,"br") /* Only used for FMTs */
- #define aopenout(f) Openout(&(f),"w") /* Always open outputs in cwd */
- #define bopenout(f) Openout(&(f),"bw")
- #define wopenout(f) Openout(&(f),"bw")
- #define aclose(f) (void) fclose(f)
- #define bclose(f) (void) fclose(f)
- #define wclose(f) (void) fclose(f)
- #define addr(x) ((char *) &(x))
- #define read(f, c) (c = getc(f))
- #define input stdin
- #define output stdout
- #define true 1
- #define false 0
- #define chr(x) (x)
- #define trunc(x) toint(x)
- #define round(x) toint(x + 0.5)
- #define dateandtime(i,j,k,l) get_date_and_time(&(i), &(j), &(k), &(l))
- #define putfmtword(x) (void) fwrite((char *) &(x), sizeof(x), 1, fmtfile)
- #define putfmthh(x) (void) fwrite((char *) &(x), sizeof(x), 1, fmtfile)
- #define putfmtqqqq(x) (void) fwrite((char *) &(x), sizeof(x), 1, fmtfile)
- #define putfmtint(x) putlw((long)x,fmtfile)
- #define getfmtword(x) (void) fread((char *) &(x), sizeof(x), 1, fmtfile)
- #define getfmthh(x) (void) fread((char *) &(x), sizeof(x), 1, fmtfile)
- #define getfmtqqqq(x) (void) fread((char *) &(x), sizeof(x), 1, fmtfile)
- #define getfmtint(x) (void) fread((char *) &(x), sizeof(x), 1, fmtfile)
-
- /*
- * Global Types --- many simulate equivalent Pascal types
- */
- typedef float real;
- typedef FILE *alphafile, *bytefile, *wordfile;
- typedef long integer;
- typedef char boolean;
- typedef unsigned char quarterword;
- typedef unsigned int halfword;
- typedef float glueratio;/* to save space in the mem structure. */
- typedef char *ccharpointer;
-
- /*
- * Global Datastructures too hard to translate automatically from Pascal.
- */
-
- typedef union {
- struct {
- halfword RH, LH;
- } v;
- struct {
- halfword junk_space; /* Make B0,B1 overlap LH in memory */
- quarterword B0, B1;
- } u;
- } twohalves;
- #define b0 u.B0
- #define b1 u.B1
-
- typedef struct {
- struct {
- quarterword B0;
- quarterword B1;
- } u;
- quarterword b2;
- quarterword b3;
- } fourquarters;
-
- typedef union {
- integer cint;
- glueratio gr;
- twohalves hh;
- fourquarters qqqq;
- } memoryword;
-